from django.contrib import admin
from django.contrib.auth.models import User
from .models import UserProfile

# Register your models here.
from django.contrib.auth.admin import UserAdmin

admin.site.unregister(User)

# 定义关联对象的样式，StackedInline为纵向排列每一行，TabularInline为并排排列
class UserProfileInline(admin.StackedInline):
# class UserProfileInline(admin.TabularInline):
    model = UserProfile   # 关联的模型

# 关联UserProfile,这里继承UserAdmin
class UserProfileAdmin(UserAdmin):
    # 内联UserProfile
    inlines = [UserProfileInline]


# 注册User模型
admin.site.register(User, UserProfileAdmin)
